package ex3.matchmaker;

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.List;
import ex3.Constants.*;

/**
 * Remote interface for matchmaker objects.
 * @author rmn
 */
public interface Matchmaker extends Remote {
	/**
	 * Returns a unique integer (>0) to serve as an ID for executors.
	 * @return an integer greater than zero.
	 * @throws RemoteException
	 */
	public int assignExecutorID() throws RemoteException;
	
	/**
	 * This function should be called by executors to notify the matchmaker of their
	 * updated state and capability list.
	 * @param bindName the bind name of the updating executor.
	 * @param state current executor state.
	 * @param capabilities current capability list of the calling executor.
	 * @throws RemoteException
	 */
	public void updateExecutor(String bindName, State state, List<Character> capabilities) throws RemoteException;
	
	/**
	 * Returns a unique integer (>0) to serve as an ID for task queues.
	 * @return an integer greater than zero.
	 * @throws RemoteException
	 */
	public int assignTaskQueueID() throws RemoteException;
	
	/**
	 * This function should be called by task queues when an executor is needed to carry 
	 * out a specific job (aka capability).
	 * If there is no executor up for the task at hand, null will be returned, and the 
	 * calling task queue's name will be added to the waiting list of the specified capability.
	 * @param capability the desired capability (returned executor must support this)
	 * @param taskQueueBindName the bind name of the calling task queue.
	 * @return a string represesnting the bind name of the allocated executor for the job,
	 * and null if there isn't one.
	 * @throws RemoteException
	 */
	public String getExecutor (Character capability, String taskQueueBindName) throws RemoteException;
}
